/*
 * @lc app=leetcode.cn id=520 lang=java
 *
 * [520] 检测大写字母
 */

// @lc code=start
class Solution {
    public boolean detectCapitalUse(String word) {
        int count = 0;
        for (char c : word.toCharArray()) {
            if (c >= 'A' && c <= 'Z') {
                count++;
            }
        }

        return count == word.length() || count == 0 || (count == 1 && word.charAt(0) >= 'A' && word.charAt(0) <= 'Z');
    }
}
// @lc code=end
